//
//  ILPlayerLiveAlImpl.h
//  IMIHome
//  Created by fangyao on 2022/07/26.
//  Copyright © 2022 上海创米科技有限公司. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ILVideoEnum.h"
#import "ILVideoViewProtocol.h"
#import <FFmpegSDK/ILEAGLView.h>
#import "ILPlayerProtocol.h"

@class ILIotAudioParams;
NS_ASSUME_NONNULL_BEGIN


@interface ILPlayerLiveAlImpl : NSObject<ILPlayerProtocol>
typedef void (^ fMediaPlayerPrepareBlock)(UIViewController* playerVC, UIView* playerView);

//添加代理
@property (nonatomic, weak) id<ILVideoViewProtocol> delegate;
//设置通话模式
@property(nonatomic, assign) BOOL useSpeakAudioModeLive;
//设备iotid
@property(nonatomic, copy) NSString *did;
@property(nonatomic, copy) NSString *model;

//是否静音
@property(nonatomic, assign, getter=isMute, setter=setMute:) BOOL mute;
//倍速
@property(nonatomic, assign, getter=getPlayerSpeed, setter=setPlayerSpeed:) ILPlayerSpeed playerSpeed;
//缩放比
@property(nonatomic, assign, setter=setScaleRatio:) CGFloat scaleRatio;
//--- 后续协议返回
//码率
@property(nonatomic, assign, readonly, getter=getBitRate) NSInteger bitRate;
  // 播放器当前状态
@property(nonatomic, assign, readonly, getter=getPlayerState) ILPlayerState playerState;
// 当前直播模式(仅适用直播)
@property(nonatomic, assign, readonly, getter=getConnetType) ILPlayerConnectType ConnectType;


//初始化
- (instancetype)initWithLivePlayer;
//设置数据源
- (BOOL)setNewDataSource:(NSDictionary *)dataSource;
//开始录像
- (BOOL)startRecord:(NSString *)filePath;
//停止录像
- (BOOL)stopRecord;
//开启对讲
- (void)startSpeak;
//关闭对讲
- (void)stopSpeak;
//截图
- (UIImage *)videoSnapshot;
//录播暂停播放
- (void)pause;

/// 23 /6/14 处理渲染相关不应该放在播放器内部 转移到ILVideoView
////仅录播、实时流 设置畸变校准，enable=false时 x，y，r无效
//- (void)setLensCorrect:(BOOL)enable x:(CGFloat)x y:(CGFloat)y r:(CGFloat)r;
////设置屏幕水平分割模式  renderSplitMode: 参考 ffmpegSDk 下  RenderSplitMode 枚举
//- (void)setSplitHorizontalMode:(NSInteger)mode;

//仅实时流
- (void)voiceChange:(int)type;  //变声
//设置录播倍速
- (void)setPlayerSpeed:(ILPlayerSpeed)playerSpeed;
//开始播放
- (void)start;
//停止播放
- (void)stop;
//激活声音
- (void)activePlayer;
//设置静音
- (void)setMute:(BOOL)isMute;

- (BOOL)isMute;
///
///获取当前播放时间
- (NSInteger)getCurrentPosition;

// 获取当前录制时长 单位 s
- (NSInteger)getRecordMP4Duration;

//录播恢复播放
- (void)restore;

- (void)destroy;

//设置直播播放源
- (BOOL)setDataSourceFromLive:(NSString *)iotId;

/// 设置直播播放源,如果没有传物模型参数,就获取本地缓存的物模型参数
/// @param iotId iotId
/// @param propertiesParams 物模型参数
- (BOOL)setDataSourceFromLive:(NSString *)iotId propertiesParams:(NSDictionary *)propertiesParams;
- (BOOL)setDataSourceLiveWithAudioParam:(NSString *)iotId audioParam:(ILAudioParams)audioParam;


////获取播放器渲染视图
//- (ILEAGLView *)getEaglView;

////设置播放源时间段
//- (void)setDataSourceFrom:(NSInteger)beginTime
//                       to:(NSInteger)endTime
//                     seek:(NSInteger)seekTime;

- (UIImage*)snapshotPicture:(void(^)(UIImage* image))finish;

/// 设置log级。  ！！！ 发布正式版本请不要打开debug 否则会自动dump 数据流到手机 消耗用户存储空间！！！！
/// - Parameter logLevel: <#logLevel description#>
- (void)setLogLevel:(ILPlayerLogLevel)logLevel;

/// 设置log级。  ！！！ 发布正式版本请不要打开debug 否则会自动dump 数据流到手机 消耗用户存储空间！！！！
/// - Parameter logLevel: <#logLevel description#>
+ (void)setLogLevel:(ILPlayerLogLevel)logLevel;

@end

NS_ASSUME_NONNULL_END

